/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.etfbl.healt;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Zoran
 */
@Entity
@Table(name = "device_has_patient")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DeviceHasPatient.findAll", query = "SELECT d FROM DeviceHasPatient d"),
    @NamedQuery(name = "DeviceHasPatient.findByCreationDate", query = "SELECT d FROM DeviceHasPatient d WHERE d.creationDate = :creationDate"),
    @NamedQuery(name = "DeviceHasPatient.findByRoom", query = "SELECT d FROM DeviceHasPatient d WHERE d.room = :room"),
    @NamedQuery(name = "DeviceHasPatient.findById", query = "SELECT d FROM DeviceHasPatient d WHERE d.id = :id")})
public class DeviceHasPatient implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Creation_Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationDate;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "Room")
    private String room;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @JoinColumn(name = "Patient_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Patient patientid;
    @JoinColumn(name = "Medical_Staff_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private MedicalStaff medicalStaffid;
    @JoinColumn(name = "Device_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Device deviceid;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "devicehasPatientid")
    private Collection<LatestActivity> latestActivityCollection;

    public DeviceHasPatient() {
    }

    public DeviceHasPatient(Integer id) {
        this.id = id;
    }

    public DeviceHasPatient(Integer id, Date creationDate, String room) {
        this.id = id;
        this.creationDate = creationDate;
        this.room = room;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public String getRoom() {
        return room;
    }

    public void setRoom(String room) {
        this.room = room;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Patient getPatientid() {
        return patientid;
    }

    public void setPatientid(Patient patientid) {
        this.patientid = patientid;
    }

    public MedicalStaff getMedicalStaffid() {
        return medicalStaffid;
    }

    public void setMedicalStaffid(MedicalStaff medicalStaffid) {
        this.medicalStaffid = medicalStaffid;
    }

    public Device getDeviceid() {
        return deviceid;
    }

    public void setDeviceid(Device deviceid) {
        this.deviceid = deviceid;
    }

    @XmlTransient
    public Collection<LatestActivity> getLatestActivityCollection() {
        return latestActivityCollection;
    }

    public void setLatestActivityCollection(Collection<LatestActivity> latestActivityCollection) {
        this.latestActivityCollection = latestActivityCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DeviceHasPatient)) {
            return false;
        }
        DeviceHasPatient other = (DeviceHasPatient) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "net.etfbl.healt.DeviceHasPatient[ id=" + id + " ]";
    }
    
}
